<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_Cancel manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> Cancel</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="Cancel.htm#M2" NAME="L71">NAME</A>
<DL><DD>Tcl_CancelEval, Tcl_Canceled &mdash; cancel Tcl scripts</DD></DL>
<DD><A HREF="Cancel.htm#M3" NAME="L72">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tcl.h&gt;</B>
<DD>int
<DD><B>Tcl_CancelEval</B>(<I>interp, resultObjPtr, clientData, flags</I>)
<DD>int
<DD><B>Tcl_Canceled</B>(<I>interp, flags</I>)
</DL>
<DD><A HREF="Cancel.htm#M4" NAME="L73">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="Cancel.htm#M5" NAME="L74">DESCRIPTION</A>
<DD><A HREF="Cancel.htm#M6" NAME="L75">FLAG BITS</A>
<DL class="flag bits">
<DD><A HREF="Cancel.htm#M7" NAME="L76"><B>TCL_CANCEL_UNWIND</B></A>
<DD><A HREF="Cancel.htm#M8" NAME="L77"><B>TCL_LEAVE_ERR_MSG</B></A>
</DL>
<DD><A HREF="Cancel.htm#M9" NAME="L78">SEE ALSO</A>
<DD><A HREF="Cancel.htm#M10" NAME="L79">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tcl_CancelEval, Tcl_Canceled &mdash; cancel Tcl scripts
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
int<BR>
<B>Tcl_CancelEval</B>(<I>interp, resultObjPtr, clientData, flags</I>)<BR>
int<BR>
<B>Tcl_Canceled</B>(<I>interp, flags</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter in which to cancel the script.
<P><DT><A HREF="../TclLib/Object.htm">Tcl_Obj</A> <B>*resultObjPtr</B> (in)<DD>
Error message to use in the cancellation, or NULL to use a default message. If
not NULL, this object will have its reference count decremented before
<B>Tcl_CancelEval</B> returns.
<P><DT>int <B>flags</B> (in)<DD>
ORed combination of flag bits that specify additional options.
For <B>Tcl_CancelEval</B>, only <B>TCL_CANCEL_UNWIND</B> is currently
supported.  For <B>Tcl_Canceled</B>, only <B>TCL_LEAVE_ERR_MSG</B> and
<B>TCL_CANCEL_UNWIND</B> are currently supported.
<P><DT>ClientData <B>clientData</B> (in)<DD>
Currently reserved for future use.
It should be set to NULL.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_CancelEval</B> cancels or unwinds the script in progress soon after
the next invocation of asynchronous handlers, causing <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> to be
the return code for that script.  This function is thread-safe and may be
called from any thread in the process.
<P>
<B>Tcl_Canceled</B> checks if the script in progress has been canceled and
returns <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> if it has.  Otherwise, <B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B> is returned.
Extensions can use this function to check to see if they should abort a long
running command.  This function is thread sensitive and may only be called
from the thread the interpreter was created in.
<H4><A NAME="M6">FLAG BITS</A></H4>
Any ORed combination of the following values may be used for the
<I>flags</I> argument to procedures such as <B>Tcl_CancelEval</B>:
<P>
<DL class="flag bits">
<DT><A NAME="M7"><B>TCL_CANCEL_UNWIND</B></A><DD>
This flag is used by <B>Tcl_CancelEval</B> and <B>Tcl_Canceled</B>.
For <B>Tcl_CancelEval</B>, if this flag is set, the script in progress
is canceled and the evaluation stack for the interpreter is unwound.
For <B>Tcl_Canceled</B>, if this flag is set, the script in progress
is considered to be canceled only if the evaluation stack for the
interpreter is being unwound.
<P><DT><A NAME="M8"><B>TCL_LEAVE_ERR_MSG</B></A><DD>
This flag is only used by <B>Tcl_Canceled</B>; it is ignored by
other procedures.  If an error is returned and this bit is set in
<I>flags</I>, then an error message will be left in the interpreter's
result, where it can be retrieved with <B><A HREF="../TclLib/SetResult.htm">Tcl_GetObjResult</A></B> or
<B><A HREF="../TclLib/SetResult.htm">Tcl_GetStringResult</A></B>.  If this flag bit is not set then no error
message is left and the interpreter's result will not be modified.
<P></DL>
<H3><A NAME="M9">SEE ALSO</A></H3>
<B><A HREF="../TclCmd/interp.htm">interp</A></B>, <B><A HREF="../TclLib/Eval.htm">Tcl_Eval</A></B>, <B>TIP 285</B>
<H3><A NAME="M10">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#cancel">cancel</A>, <A href="../Keywords/U.htm#unwind">unwind</A>
<div class="copy">Copyright &copy; 2006-2008 Joe Mistachkin.
</div>
</BODY></HTML>
